/*
 * @Author: 火红色祥云 809880192@qq.com
 * @Date: 2023-03-09 19:16:27
 * @LastEditors: 火红色祥云 809880192@qq.com
 * @LastEditTime: 2023-03-12 11:11:10
 * @FilePath: /imx6ull-app/21_mpu6050/21_AppMpu6050.c
 * @Description: mpu6050驱动应用程序
 */
#include <stdlib.h>
#include <stdio.h>
#include <string.h>

#include "unistd.h"
#include "fcntl.h"

int main(int argc, char const *argv[])
{
    int fd;
    short databuf[7];

    if (argc != 2)
    {
        perror("Usage error is not 2\r\n");
        return -1;
    }
    
    fd = open(argv[1],O_RDWR);
    if (fd < 0)
    {
        perror("open fail \r\n");
        return -1;
    }
    memset(databuf,0,sizeof(databuf));

    while (1)
    {
        read(fd,databuf,sizeof(databuf));

        printf("gx:gy:gz:ax:zy:az: %d-%d-%d-%d-%d-%d\r\n",databuf[1],databuf[2],databuf[3],databuf[4],databuf[5],databuf[6]);

        usleep(200000);
    }
    
    
    close(fd);

    return 0;
}
